<?php defined('IN_NWIDC') or exit('Access Invalid!');?>
<script src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.ajaxContent.pack.js"></script>
<script src="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/i18n/zh-CN.js"></script>
<script src="<?php echo RESOURCE_SITE_URL;?>/js/common_select.js"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/fileupload/jquery.iframe-transport.js" charset="utf-8"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/fileupload/jquery.ui.widget.js" charset="utf-8"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/fileupload/jquery.fileupload.js" charset="utf-8"></script>
<script src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.poshytip.min.js"></script>
<script src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.mousewheel.js"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.charCount.js"></script>
<!--[if lt IE 8]>
  <script src="<?php echo RESOURCE_SITE_URL;?>/js/json2.js"></script>
<![endif]-->
<script src="<?php echo SHOP_RESOURCE_SITE_URL;?>/js/store_goods_add.step2.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/themes/ui-lightness/jquery.ui.css"  />
<style type="text/css">
#fixedNavBar { filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#CCFFFFFF', endColorstr='#CCFFFFFF');background:rgba(255,255,255,0.8); width: 90px; margin-left: 510px; border-radius: 4px; position: fixed; z-index: 999; top: 172px; left: 50%;}
#fixedNavBar h3 { font-size: 12px; line-height: 24px; text-align: center; margin-top: 4px;}
#fixedNavBar ul { width: 80px; margin: 0 auto 5px auto;}
#fixedNavBar li { margin-top: 5px;}
#fixedNavBar li a { font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px; background-color: #F5F5F5; color: #999; text-align: center; display: block;  height: 20px; border-radius: 10px;}
#fixedNavBar li a:hover { color: #FFF; text-decoration: none; background-color: #27a9e3;

}
.goodsextends{
    display: none;
}

#_result dl,._margin{
  background: #eee;
}
</style>
<?php
if (!empty($_GET['commonid'])) {
  $goods_info = Model()->table('goods')->where('goods_commonid =' . $_GET['commonid'])->find();
  $gminfo = Model('goods_common')->find($_GET['commonid']);
}
else{
  $goods_info = array();
  $gminfo = array();
}
?>
<div id="fixedNavBar">
<h3>页面导航</h3>
  <ul>
    <li><a id="demo1Btn" href="#demo1" class="demoBtn">基本信息</a></li>
    <li><a id="demo2Btn" href="#demo2" class="demoBtn">详情描述</a></li>
    <li><a id="demo3Btn" href="#demo3" class="demoBtn">特殊商品</a></li>
    <li><a id="demo4Btn" href="#demo4" class="demoBtn">物流运费</a></li>
    <li><a id="demo5Btn" href="#demo5" class="demoBtn">发票信息</a></li>
    <li><a id="demo6Btn" href="#demo6" class="demoBtn">其他信息</a></li>
  </ul>
</div>
<?php if ($output['edit_goods_sign']) {?>
<div class="tabmenu">
  <?php include template('layout/submenu');?>
</div>
<?php } else {?>
<ul class="add-goods-step">
  <li><i class="icon icon-list-alt"></i>
    <h6>STEP.1</h6>
    <h2>选择商品分类</h2>
    <i class="arrow icon-angle-right"></i> </li>
  <li class="current"><i class="icon icon-edit"></i>
    <h6>STEP.2</h6>
    <h2>填写商品详情</h2>
    <i class="arrow icon-angle-right"></i> </li>
  <li><i class="icon icon-camera-retro "></i>
    <h6>STEP.3</h6>
    <h2>上传商品图片</h2>
    <i class="arrow icon-angle-right"></i> </li>
  <li><i class="icon icon-ok-circle"></i>
    <h6>STEP.4</h6>
    <h2>商品发布成功</h2>
  </li>
</ul>
<?php


}?>
<div class="item-publish">
  <form method="post" id="goods_form" action="<?php if ($output['edit_goods_sign']) { echo urlShop('store_goods_online', 'edit_save_goods');} else { echo urlShop('store_goods_add', 'save_goods');}?>">
    <input type="hidden" name="form_submit" value="ok" />
    <input type="hidden" name="commonid" value="<?php echo $output['goods']['goods_commonid'];?>" />
    <input type="hidden" name="type_id" value="<?php echo $output['goods_class']['type_id'];?>" />
    <input type="hidden" name="ref_url" value="<?php echo $_GET['ref_url'] ? $_GET['ref_url'] : getReferer();?>" />
    <div class="ncsc-form-goods">
      <h3 id="demo1"><?php echo $lang['store_goods_index_goods_base_info']?></h3>
      <dl>
        <dt><?php echo $lang['store_goods_index_goods_class'].$lang['nc_colon'];?></dt>
        <dd id="gcategory"> <?php echo $output['goods_class']['gc_tag_name'];?> <a class="ncsc-btn" href="<?php if ($output['edit_goods_sign']) { echo urlShop('store_goods_online', 'edit_class', array('commonid' => $output['goods']['goods_commonid'], 'ref_url' => getReferer())); } else { echo urlShop('store_goods_add', 'add_step_one'); }?>"><?php echo $lang['nc_edit'];?></a>
          <input type="hidden" id="cate_id" name="cate_id" value="<?php echo $output['goods_class']['gc_id'];?>" class="text" />
          <input type="hidden" name="cate_name" value="<?php echo $output['goods_class']['gc_tag_name'];?>" class="text"/>
        </dd>
      </dl>
      <?php

      $model_setting = Model('setting');
      $config = $model_setting->getListSetting();
      if($config['open_tax'] == 1){

      ?>
      <dl>
        <dt>
          <i class="required">*</i>
          商品类别：
        </dt>
        <dd>
          <?php
            if(isset($output['goods']['open_tax'])){
              echo $output['goods']['open_tax'] == 0 ? '国内完税商品' : "保税商品";
            }
          ?>

          <ul class="ncsc-form-radio-list" style='<?php  if(isset($output['goods']['open_tax'])){ echo "display:none;";}?>'>
            <li>
              <label>
              <input name="goods_type" class="radio" type="radio"   value="0">
              国内完税商品
              </label>
            </li>
            <?php
              $sinfo = Model('store')->where(array('member_id' => $_SESSION['member_id']))->find();
              if(!empty($sinfo['ebcName'])){
            ?>
            <li>
              <label><input name="goods_type" class="radio" type="radio" <?php if($output['goods']['open_tax'] > 0){ ?>checked="checked"<?php }?> value="1">
              保税商品</label>
            </li>
            <?php
              }
            ?>
          </ul>


          <script>
            $('[name=goods_type]').click(function(){
              if(this.value == 1 && this.checked){
                $('.goodsextends').slideDown();
              }
              else if(this.value == 0 && this.checked){
                $('.goodsextends').slideUp();
              }
            });

          </script>
           <span></span>
            <p class="hint">商品类别一经确定无法修改，请谨慎选择</p>
        </dd>

      </dl>

      <?php
      ?>
      <dl style="" class=''>
          <dt>
            所属场馆：
          </dt>
          <dd class="spec">
            <select name="from_place" id="place">
              <option value="-1">无</option>
              <?php
                $ps = Model('place')->select();
                foreach($ps as $p){
              ?>
              <option value="<?php echo $p[id]?>"><?php echo $p['name']?></option>
              <?php
                }
              ?>
            </select>

            <select name="brand_id" id="sel_brand">
              <option value="0" >无</option>
              <?php
                $bs = Model('brand')->page(10000)->select();
                foreach($bs as $b){
              ?>
              <option value="<?php echo $b['brand_id']?>" from_place='<?php echo $b['from_place']?>'><?php echo $b['brand_name']?></option>
              <?php
                }
              ?>
            </select>
            <span></span>
            <p class="hint">
              场馆和品牌均可以不填写
            </p>
          </dd>
      </dl>

      <script>
      (function(){
        function init(){
          $('option[from_place]').show();
        }

        $('#place').change(function(){
          var val = this.value;
          if(val == -1){
            init();
            // $('#_result').hide();
          }
          else{
            $('option[from_place]').hide();
            $('#sel_brand option:first').show().attr('selected','selected').siblings().removeAttr('selected');
            $('option[from_place='+val+']').show();
          }
        });

        $(function(){
          var target = '<?php echo $output['goods']['from_place']?>';
          if(Number(target) > 0){
              $('[name=from_place]').val(target).find('option[value=' + target + ']').attr('selected','selected').siblings().removeAttr('selected').trigger('change');
              $('#sel_brand').val(<?php echo $output['goods']['brand_id']?>).find('option[value=' + <?php echo $output['goods']['brand_id']?> + ']').attr('selected','selected').siblings().removeAttr('selected').trigger('change');
          }
        });

      })();



      </script>

      <div style='display: none!important;'>
        <dl class='_margin goodsextends'>
            <dt>
              <i class="required">*</i>
              商品税率：
            </dt>
            <dd nc_type="no_spec">
            <input name="margin" value="<?php echo $output['goods']['tax'];?>" type="text" class="text w60"><em class="add-on">%</em>
            <span></span>
            <p class="hint">税率必须在0%-100%之间，填写0即视为完税产品，请按照相关规定进行设置。</p>
          </dd>
        </dl>
        <script>
          $(function(){
              $(document).on("change",'[name=codeTs]',function(){
                  var val = $(this).find('option[value=' + this.value + ']').text();
                  var rate = val.match(/(\d+)%/)[1];
                  $('[name=margin]').val(rate);
              });
          });
        </script>
      </div>


      <div id='_result'>
      <?php
          if($config['custom_interface'] == 'shenzhen'){
      ?>
        <link rel="stylesheet" href="/static/webuploader/webuploader.css">
        <style>
        .webuploader-pick{
          height: 30px;
          padding: 0 15px;
        }
        .sel,.sel2{
          width: 60px;
          height: 30px;
        }
        .sel input,.sel div,.sel2 input, .sel2 div{
          display: block;
          width: 60px;
          height: 30px;
        }
        .file-item{
          overflow: hidden;
          margin-bottom: 5px;
        }
        .file-item .info{
          float: left;
          margin-right: 10px;
        }
        .image_list{
          padding-top: 10px;
        }
        .file_list{
          padding-top: 10px;
        }

        </style>
        <script src='/static/webuploader/webuploader.min.js'></script>

        <dl style='' class='goodsextends imageupload' >
          <dt>
            <i class="required">*</i>
            备案图片：
          </dt>
          <dd nc_type="no_spec">
            <div class='sel'>上传图片</div>
            <div class='image_list'></div>
            <span></span>

            <p class="hint">备案图片应至少有4张，分别为正面、侧面、背面、标签。</p>
          </dd>
        </dl>

        <dl style='' class='goodsextends fileupload' >
          <dt>
            <i class="required">*</i>
            附件：
          </dt>
          <dd nc_type="no_spec">
            <div class='sel2'>上传附件</div>
            <div class='file_list'></div>
            <span></span>

            <p class="hint">附件可以为空。</p>
          </dd>
        </dl>

        <script>
        var BASE_URL = '/static/webuploader';
      (function(){
        var uploader = WebUploader.create({

            // swf文件路径
            swf: BASE_URL + '/Uploader.swf',
            // 文件接收服务端。
            server: '/static/webuploader/fileupload.php',
            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '.sel',
            // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
            resize: false,

            auto : true,

            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: 'image/*'
            }
        });

      var $list = $('.image_list');

      uploader.on( 'fileQueued', function( file ) {

      var $li = $(
            '<div id="' + file.id + '" class="file-item thumbnail">' +
                '<div class="info"><a href="javascript:;"><img></a></div>' +
                '<div class="info" style="padding-top:5px"><select name="pictype[]"><option value="1">正面</option><option value="2">背面</option><option value="3">侧面</option><option value="4">标签</option></select></div>' +
                '<div class="info uploading" style="padding-top:5px">上传中……</div>' +
                '<div class="info" style="padding-top:5px;"><input type="hidden" name="pics[]"/><a href="javascript:;" class="_remove">删除</a>' + '</div>' +
            '</div>'
            ),
            $img = $li.find('img');



            // $list为容器jQuery实例
            $list.append( $li );

            // 创建缩略图
            // 如果为非图片文件，可以不用调用此方法。
            // thumbnailWidth x thumbnailHeight 为 100 x 100
            uploader.makeThumb( file, function( error, src ) {
                if ( error ) {
                    $img.replaceWith('<span>不能预览</span>');
                    return;
                }

                $img.attr( 'src', src );
            }, 50, 50 );
        });

        uploader.on( 'uploadSuccess', function( file , response ) {
          $( '#'+file.id ).find('a:first').attr({
            href : '/static/webuploader/' + response.result,
            target : '_blank'
          })
          $('#' + file.id).find('.uploading').text('上传成功');
          // $( '#'+file.id ).find('.info:first').text(file.name);
          $( '#'+file.id ).find('.info input[type=hidden]').val('/static/webuploader/' + response.result);
        });
        uploader.on( 'uploadError', function( file ) {
          alert('上传出错！');
            $( '#'+file.id ).remove();
        });

        $(document).on('click','._remove',function(){
          $(this).closest('.file-item').remove();
        })

          })();
        </script>

        <script>
          (function(){
          var uploader = WebUploader.create({

            // swf文件路径
            swf: BASE_URL + '/Uploader.swf',
            // 文件接收服务端。
            server: '/static/webuploader/fileupload.php',
            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '.sel2',
            // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
            resize: false,

            auto : true
        });

      var $list = $('.file_list');

      uploader.on( 'fileQueued', function( file ) {

      var $li = $(
            '<div id="' + file.id + '" class="file-item thumbnail">' +
                '<div class="info"><a href="javascript:;"></a></div>' +
                '<div class="info" style="padding-top:5px"><select name="filetype[]"><option value="01">第三方检测报告</option><option value="02">原产国（地区）自由销售证明</option><option value="03">3C认证证书</option><option value="04">3C无需办理证明</option><option value="05">3C免办证明（手册）</option><option value="06">技术说明（3C目录外）</option><option value="07">中检界定结果（3C目录外）</option><option value="08">检验检疫界定结果（3C目录外）</option><option value="09">进口保健食品批准证书</option><option value="10">原产地证明</option><option value="11">婴幼儿乳粉的全项目检测报告</option><option value="12">化妆品备案凭证</option><option value="13">食品新品种、新原料的进口许可</option><option value="14">食品/化妆品相关证明材料（如产品成分、原料及配比、加工工艺说明等）</option><option value="15">《入/出境特殊物品卫生检疫审批单》</option><option value="16">《行政许可申请不予受理决定书》 </option><option value="99">其他</option></select></div>' +
                '<div class="info uploading" style="padding-top:5px">上传中……</div>' +
                '<div class="info" style="padding-top:5px;"><input type="hidden" name="files[]"/><a href="javascript:;" class="_remove">删除</a>' + '</div>' +
            '</div>'
            );
        $li.find('a:first').text(file.name);

            // $list为容器jQuery实例
            $list.append( $li );

        });

        uploader.on( 'uploadSuccess', function( file , response ) {
          $( '#'+file.id ).find('a:first').attr({
            href : '/static/webuploader/' + response.result,
            target : '_blank'
          })
          $('#' + file.id).find('.uploading').text('上传成功');
          // $( '#'+file.id ).find('.info:first').text(file.name);
          $( '#'+file.id ).find('.info input[type=hidden]').val('/static/webuploader/' + response.result);
        });
        uploader.on( 'uploadError', function( file ) {
          alert('上传出错！');
            $( '#'+file.id ).remove();
        });
          })();
        </script>


      <?php
          }
      ?>

      </div>



      <script>
        (function(){
          //@tag
          <?php
            $base = dirname(BASE_PATH);
            require_once $base . '/custom/'.$config['custom_interface'].'/controller.php';
            $class = $config['custom_interface'] . 'Controller';
            $custom = new $class;


          ?>
          var config = <?php echo json_encode($custom->get_form('goods'))?>;
          // console.log(config);
          var linkarr = [];
          for(var i in config){
            var item = config[i];
            var base = $('._margin').clone().removeClass('_margin');
            if(!is(item,'object') || is(item,"array")){
              continue;
            }
            var input;

            if(item.type){
              switch(item.type){
                case 'text':
                  input = $('<input>').attr({
                    'class' : 'text w400',
                    'type' : 'text',
                    'name' : i
                  });
                  break;

                case 'select':
                  input = $('<select>').attr({
                    'name' : i
                  });
                  input.append('<option value="">请选择</option>');
                  if(item.options){
                    for(var j in item.options){
                      input.append("<option value='"+j+"'>"+item.options[j]+"</option>")
                    }
                  }
                  break;
                case 'upload':
                  input = $('<input>').attr({
                    'name' : i,
                    "type" : "file"
                    // "class" : ""
                  });
                  break;


                case 'hidden':
                  input = $('<input type="hidden" name="'+i+'" />');
                  break;
              }
            }

            if(item.name){
              if(item.empty == true){
                base.find('dt').html(item.name  + '：');
              }
              else{
                 base.find('dt').html('<i class="required">*</i>' + item.name + '：');
              }
            }
            else{
              base.find('dt').empty();
            }
            base.find('p.hint').empty();
            if(item.tip){
              base.find('p.hint').html(item.tip);
            }
            base.find('dd').find('input,em').remove();
            if(input){
              input.insertBefore(base.find('span'));
              if(item.after){
                $('<em class="add-on">'+item.after+'</em>').insertAfter(input);
              }

              if(item.link){
                linkarr.push({
                  'source' : i,
                  'target' : item.link
                })
              }
            }
            if(item.type == 'hidden'){
              $('#_result').append(input);
            }else{
              $('#_result').append(base);
            }
          }

          var getValue = function(arr,name){
            var item = $('[name=' + arr[0] + ']');

            item.change(function(){
              if(arr[1] == 'text'){
                if(item[0].tagName == 'SELECT'){
                  var val = item.find('option:selected').text();
                }
                else{
                  var val = item.text();
                }
              }
              else{
                var val = item[0].value;
              }
              $('[name=' + name + ']').val(val);
            });
          }

          for(var i = 0; i < linkarr.length; i++){
            var target = linkarr[i].target;
            if(target.indexOf('.')){
              var arr = target.split('.');
              getValue(arr,linkarr[i].source)

            }
          }


        })();

        function is(o, type) {
          var isnan = {"NaN": 1, "Infinity": 1, "-Infinity": 1}
          type = type.toLowerCase();

          // {"NaN": 1, "Infinity": 1, "-Infinity": 1}.hasOwnProperty(2)   -> false
          // {"NaN": 1, "Infinity": 1, "-Infinity": 1}.hasOwnProperty(NaN) -> true
          if (type == "finite") {
            return !isnan["hasOwnProperty"](+o);
          }
          if (type == "array") {
            return o instanceof Array;
          }
          return  (type == "null" && o === null) ||
            // is(undefined,'undefined')
            (type == typeof o && o !== null) ||
            // Object(Object) == Object -> true
            // Object({}) == {}         -> false
            (type == "object" && o === Object(o)) ||
            (type == "array" && Array.isArray && Array.isArray(o)) ||
            Object.prototype.toString.call(o).slice(8, -1).toLowerCase() == type;
        }
      </script>


      <!--
      <script>
        <?php
            if(isset($output['goods']['gextends'])){
                $output['goods']['gextends'] = unserialize($output['goods']['gextends']);
            }
            $gdata = json_encode($output['goods']);
            if(isset($output['goods']['goods_commonid'])){
        ?>
        var gdata = <?php echo $gdata?>
        <?php
            }
        ?>
      </script>

      <script src='/data/resource/js/goodsextends.js'></script>
      -->
    <?php
      $_m = Model();
      $ginfo = $_m->table('custom_' . $config['custom_interface'] . '_goods')->where(array('goods_commonid' => $output['goods']['goods_commonid']))->find();
      // if(!empty($ginfo['gextends'])){
      //   $output['goods']['gextends'] = $ginfo['gextends'];
      // }
      // if(isset($output['goods']['gextends'])){
      //   if(!is_array($output['goods']['gextends'])){
      //     $output['goods']['gextends'] = unserialize($output['goods']['gextends']);
      //   }
      // }

    ?>
      <script>
        $('[name=goods_type]:checked').trigger('click');
        var ginfo = <?php echo json_encode($ginfo)?>;
        if(ginfo){
          for(var i in ginfo){
            var item = $('#_result [name=' + i + ']');
            if(!item.length){
              continue;
            }
            if(item[0].tagName == 'SELECT'){
              item.find('option[value=' + ginfo[i] + ']').attr('selected','selected').siblings().removeAttr('selected');
            }
            else{
              item.val(ginfo[i]);
            }
          }
        }

        var image_list = eval('(' + ginfo.ImageList + ')');
        var base = $('<div class="file-item thumbnail">' +
                '<div class="info"><a href="javascript:;"><img></a></div>' +
                '<div class="info" style="padding-top:5px"><select name="pictype[]"><option value="1">正面</option><option value="2">背面</option><option value="3">侧面</option><option value="4">标签</option></select></div>' +
                '<div class="info" style="padding-top:5px;"><input type="hidden" name="pics[]"/><a href="javascript:;" class="_remove">删除</a>' + '</div>' +
            '</div>');
        for(var i in image_list){
          var cl = base.clone();
          // alert(image_list[i].image)
          cl.find('img').attr('src',image_list[i].image).css({width:50,height:50});
          cl.find('select option[value=' + image_list[i].imageType + ']').attr('selected','selected');
          cl.find('input[name="pics[]"]').val(image_list[i].image);
          $('.image_list').append(cl);
          // image_list.find
        }
        var image_list = eval('(' + ginfo.AttachmentList + ')');
        var base = $(
            '<div class="file-item thumbnail">' +
                '<div class="info"><a href="javascript:;"></a></div>' +
                '<div class="info" style="padding-top:5px"><select name="filetype[]"><option value="01">第三方检测报告</option><option value="02">原产国（地区）自由销售证明</option><option value="03">3C认证证书</option><option value="04">3C无需办理证明</option><option value="05">3C免办证明（手册）</option><option value="06">技术说明（3C目录外）</option><option value="07">中检界定结果（3C目录外）</option><option value="08">检验检疫界定结果（3C目录外）</option><option value="09">进口保健食品批准证书</option><option value="10">原产地证明</option><option value="11">婴幼儿乳粉的全项目检测报告</option><option value="12">化妆品备案凭证</option><option value="13">食品新品种、新原料的进口许可</option><option value="14">食品/化妆品相关证明材料（如产品成分、原料及配比、加工工艺说明等）</option><option value="15">《入/出境特殊物品卫生检疫审批单》</option><option value="16">《行政许可申请不予受理决定书》 </option><option value="99">其他</option></select></div>' +
                '<div class="info" style="padding-top:5px;"><input type="hidden" name="files[]"/><a href="javascript:;" class="_remove">删除</a>' + '</div>' +
            '</div>'
            );
        for(var i in image_list){
          var cl = base.clone();
          // alert(image_list[i].image)
          cl.find('a:first').text(image_list[i].attachment.match(/[^\/]+$/));
          cl.find('select option[value=' + image_list[i].attachmentType + ']').attr('selected','selected');
          cl.find('input[name="files[]"]').val(image_list[i].attachment);
          $('.file_list').append(cl);
          // image_list.find
        }

        $('#_result').find('input,select').trigger('change');
      </script>

      <?php }?>

      <dl>
        <dt><i class="required">*</i><?php echo $lang['store_goods_index_goods_name'].$lang['nc_colon'];?></dt>
        <dd>
          <input name="g_name" id='goods_name' type="text" maxlength="50" class="text w400" value="<?php echo $output['goods']['goods_name']; ?>" />
          <span></span>
          <p class="hint"><?php echo $lang['store_goods_index_goods_name_help'];?></p>
        </dd>
      </dl>
      <script>
      var elem = document.getElementById('goods_name');
      if(document.addEventListener){
        elem.addEventListener('input',function(){
            var val = elem.value;
            var x = 50 - val.length;
            $(elem).next().text('   （还可以录入' + x + '字）');
        })
      }else{
        elem.attachEvent('onpropertychange',function(){
            var e = window.event;
            if(e.propertyName == 'value'){
              var val = elem.value;
              var x = 50 - val.length;
              $(elem).next().text('   （还可以录入' + x + '字）');
            }
        });
      }
      </script>
      <dl>
          <dt>
            <i class="required">*</i>
            产品条形码：
          </dt>
          <dd nc_type="no_spec">
          <input name="sharp" value="<?php echo $output['goods']['sharp'];?>" type="text" class="text w180">
          <span></span>
          <p class="hint"></p>
        </dd>
      </dl>
      <dl>
        <dt>商品卖点<?php echo $lang['nc_colon'];?></dt>
        <dd>
          <textarea name="g_jingle" class="textarea h60 w400"><?php echo $output['goods']['goods_jingle']; ?></textarea>
          <span></span>
          <p class="hint">商品卖点最长不能超过140个汉字</p>
        </dd>
      </dl>

      <dl>
        <dt nc_type="no_spec"><i class="required">*</i><?php echo $lang['store_goods_index_store_price'].$lang['nc_colon'];?></dt>
        <dd nc_type="no_spec">
          <input name="g_price" value="<?php echo $output['goods']['goods_price']; ?>" type="text"  class="text w60" /><em class="add-on"><i class="icon-renminbi"></i></em> <span></span>
          <p class="hint"><?php echo $lang['store_goods_index_store_price_help'];?>，且不能高于市场价。<br>
            此价格为商品实际销售价格。</p>
        </dd>
      </dl>


      <dl>
        <dt nc_type="no_spec"><i class="required">*</i>商品净重：</dt>
        <dd nc_type="no_spec">
          <input name="weight" value="<?php echo $output['goods']['weight']; ?>" type="text"  class="text w60" /><em class="add-on">克</em> <span></span>
          <p class="hint">单位为g，请填写大于0的整数</p>
        </dd>
      </dl>


      <dl>
        <dt><i class="required">*</i>市场价<?php echo $lang['nc_colon'];?></dt>
        <dd>
          <input name="g_marketprice" value="<?php echo $output['goods']['goods_marketprice']; ?>" type="text" class="text w60" /><em class="add-on"><i class="icon-renminbi"></i></em> <span></span>
          <p class="hint"><?php echo $lang['store_goods_index_store_price_help'];?>，此价格仅为市场参考售价，请根据该实际情况认真填写。</p>
        </dd>
      </dl>
      <dl>
        <dt>成本价<?php echo $lang['nc_colon'];?></dt>
        <dd>
          <input name="g_costprice" value="<?php echo $output['goods']['goods_costprice']; ?>" type="text" class="text w60" /><em class="add-on"><i class="icon-renminbi"></i></em> <span></span>
          <p class="hint">价格必须是0.00~9999999之间的数字，此价格为商户对所销售的商品实际成本价格进行备注记录，非必填选项，不会在前台销售页面中显示。</p>
        </dd>
      </dl>
      <dl style='display: none;'>
        <dt>折扣<?php echo $lang['nc_colon'];?></dt>
        <dd>
          <input name="g_discount" value="<?php echo $output['goods']['goods_discount']; ?>" type="text" class="text w60" readonly="readonly" style="background:#E7E7E7 none;" /><em class="add-on">%</em>
          <p class="hint">根据销售价与市场价比例自动生成，不需要编辑。</p>
        </dd>
      </dl>
      <?php if(is_array($output['spec_list']) && !empty($output['spec_list'])){?>
      <?php $i = '0';?>
      <?php foreach ($output['spec_list'] as $k=>$val){?>
      <dl nc_type="spec_group_dl_<?php echo $i;?>" nctype="spec_group_dl" class="spec-bg" <?php if($k == '1'){?>spec_img="t"<?php }?>>
        <dt>
          <input name="sp_name[<?php echo $k;?>]" type="text" class="text w60 tip2 tr" title="自定义规格类型名称，规格值名称最多不超过4个字" value="<?php if (isset($output['goods']['spec_name'][$k])) { echo $output['goods']['spec_name'][$k];} else {echo $val['sp_name'];}?>" maxlength="4" nctype="spec_name" data-param="{id:<?php echo $k;?>,name:'<?php echo $val['sp_name'];?>'}"/>
          <?php echo $lang['nc_colon']?></dt>
        <dd <?php if($k == '1'){?>nctype="sp_group_val"<?php }?>>
          <ul class="spec">
            <?php if(is_array($val['value'])){?>
            <?php foreach ($val['value'] as $v) {?>
            <li><span nctype="input_checkbox">
              <input type="checkbox" value="<?php echo $v['sp_value_name'];?>" nc_type="<?php echo $v['sp_value_id'];?>" <?php if($k == '1'){?>class="sp_val"<?php }?> name="sp_val[<?php echo $k;?>][<?php echo $v['sp_value_id']?>]">
              </span><span nctype="pv_name"><?php echo $v['sp_value_name'];?></span></li>
            <?php }?>
            <?php }?>
            <li data-param="{gc_id:<?php echo $output['goods_class']['gc_id'];?>,sp_id:<?php echo $k;?>,url:'<?php echo urlShop('store_goods_add', 'ajax_add_spec');?>'}">
              <div nctype="specAdd1"><a href="javascript:void(0);" class="ncsc-btn" nctype="specAdd"><i class="icon-plus"></i>添加规格值</a></div>
              <div nctype="specAdd2" style="display:none;">
                <input class="text w60" type="text" placeholder="规格值名称" maxlength="20">
                <a href="javascript:void(0);" nctype="specAddSubmit" class="ncsc-btn ncsc-btn-acidblue ml5 mr5">确认</a><a href="javascript:void(0);" nctype="specAddCancel" class="ncsc-btn ncsc-btn-orange">取消</a></div>
            </li>
          </ul>
          <?php if($output['edit_goods_sign'] && $k == '1'){?>
          <p class="hint">添加或取消颜色规格时，提交后请编辑图片以确保商品图片能够准确显示。</p>
          <?php }?>
        </dd>
      </dl>
      <?php $i++;?>
      <?php }?>
      <?php }?>
      <dl nc_type="spec_dl" class="spec-bg" style="display:none; overflow: visible;">
        <dt><?php echo $lang['srore_goods_index_goods_stock_set'].$lang['nc_colon'];?></dt>
        <dd class="spec-dd">
          <table border="0" cellpadding="0" cellspacing="0" class="spec_table">
            <thead>
              <?php if(is_array($output['spec_list']) && !empty($output['spec_list'])){?>
              <?php foreach ($output['spec_list'] as $k=>$val){?>
            <th nctype="spec_name_<?php echo $k;?>"><?php if (isset($output['goods']['spec_name'][$k])) { echo $output['goods']['spec_name'][$k];} else {echo $val['sp_name'];}?></th>
              <?php }?>
              <?php }?>
              <th class="w90"><span class="red">*</span>市场价
                <div class="batch"><i class="icon-edit" title="批量操作"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>批量设置价格：</h6>
                    <a href="javascript:void(0)" class="close">X</a>
                    <input name="" type="text" class="text price" />
                    <a href="javascript:void(0)" class="ncsc-btn-mini" data-type="marketprice">设置</a><span class="arrow"></span></div>
                </div></th>
              <th class="w90"><span class="red">*</span><?php echo $lang['store_goods_index_price'];?>
                <div class="batch"><i class="icon-edit" title="批量操作"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>批量设置价格：</h6>
                    <a href="javascript:void(0)" class="close">X</a>
                    <input name="" type="text" class="text price" />
                    <a href="javascript:void(0)" class="ncsc-btn-mini" data-type="price">设置</a><span class="arrow"></span></div>
                </div></th>
              <th class="w60"><span class="red">*</span><?php echo $lang['store_goods_index_stock'];?>
                <div class="batch"><i class="icon-edit" title="批量操作"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>批量设置库存：</h6>
                    <a href="javascript:void(0)" class="close">X</a>
                    <input name="" type="text" class="text stock" />
                    <a href="javascript:void(0)" class="ncsc-btn-mini" data-type="stock">设置</a><span class="arrow"></span></div>
                </div></th>
              <th class="w70">预警值
                <div class="batch"><i class="icon-edit" title="批量操作"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>批量设置预警值：</h6>
                    <a href="javascript:void(0)" class="close">X</a>
                    <input name="" type="text" class="text stock" />
                    <a href="javascript:void(0)" class="ncsc-btn-mini" data-type="alarm">设置</a><span class="arrow"></span></div>
                </div></th>
              <th class="w100"><?php echo $lang['store_goods_index_goods_no'];?></th>
                </thead>
            <tbody nc_type="spec_table">
            </tbody>
          </table>
          <p class="hint">点击<i class="icon-edit"></i>可批量修改所在列的值。</p>
        </dd>
      </dl>
      <dl>
        <dt nc_type="no_spec"><i class="required">*</i><?php echo $lang['store_goods_index_goods_stock'].$lang['nc_colon'];?></dt>
        <dd nc_type="no_spec">
          <input name="g_storage" value="<?php echo $output['goods']['g_storage']; ?>" type="text" class="text w60" />
          <span></span>
          <p class="hint"><?php echo $lang['store_goods_index_goods_stock_help'];?></p>
        </dd>
      </dl>
      <dl style='display: none;'>
        <dt>库存预警值<?php echo $lang['nc_colon'];?></dt>
        <dd>
          <input name="g_alarm" value="<?php echo $output['goods']['goods_storage_alarm'];?>" type="text" class="text w60" />
          <span></span>
          <p class="hint">设置最低库存预警值。当库存低于预警值时商家中心商品列表页库存列红字提醒。<br>
            请填写0~255的数字，0为不预警。</p>
        </dd>
      </dl>
      <dl>
        <dt nc_type="no_spec"><?php echo $lang['store_goods_index_goods_no'].$lang['nc_colon'];?></dt>
        <dd nc_type="no_spec">
          <p>


            <input name="g_serial" value="<?php echo $goods_info['goods_serial']; ?>" type="text"  class="text"  />
          </p>
          <p class="hint">
            商家货号是指商家管理商品的编号<Br>
            最多可输入20个字符，支持输入中文、字母、数字、_、/、-和小数点
          </p>
        </dd>
      </dl>
      <dl>
        <dt><i class="required">*</i><?php echo $lang['store_goods_album_goods_pic'].$lang['nc_colon'];?></dt>
        <dd>
          <div class="ncsc-goods-default-pic">
            <div class="goodspic-uplaod">
              <div class="upload-thumb"> <img nctype="goods_image" src="<?php echo thumb($output['goods'], 240);?>"/> </div>
              <input type="hidden" name="image_path" id="image_path" nctype="goods_image" value="<?php echo $output['goods']['goods_image']?>" />
              <span></span>
              <p class="hint"><?php echo $lang['store_goods_step2_description_one'];?><?php printf($lang['store_goods_step2_description_two'],intval(C('image_max_filesize'))/1024);?></p>
              <div class="handle">
                <div class="ncsc-upload-btn"> <a href="javascript:void(0);"><span>
                  <input onchange='return file_upload(this)' type="file" hidefocus="true" size="1" class="input-file" name="goods_image" id="goods_image">
                  </span>
                  <script>
                    function file_upload(t){
                        // console.log(t)
                        // if(t.files){
                        //   var file = t.files[0];
                        //   if(file.size > 1024 * 1024){
                        //       layer.msg('文件过大，请重新上传！');
                        //       setTimeout(function(){
                        //         $('[nctype=goods_image]').attr('src','/data/upload/shop/common/default_goods_image_240.gif')
                        //       },50)
                        //   }

                        // }
                        // return false;
                    }
                  </script>
                  <p><i class="icon-upload-alt"></i>图片上传</p>
                  </a> </div>
                <a class="ncsc-btn mt5" nctype="show_image" href="<?php echo urlShop('store_album', 'pic_list', array('item'=>'goods'));?>"><i class="icon-picture"></i>从图片空间选择</a> <a href="javascript:void(0);" nctype="del_goods_demo" class="ncsc-btn mt5" style="display: none;"><i class="icon-circle-arrow-up"></i>关闭相册</a></div>
            </div>
          </div>
          <div id="demo"></div>
        </dd>
      </dl>
      <h3 id="demo2"><?php echo $lang['store_goods_index_goods_detail_info']?></h3>
      <?php if(false){?>
      <dl style="overflow: visible;">
        <dt><?php echo $lang['store_goods_index_goods_brand'].$lang['nc_colon'];?></dt>
        <dd>
          <div class="ncsc-brand-select">
            <div class="selection">
              <input name="b_name" id="b_name" value="<?php echo $output['goods']['brand_name'];?>" type="text" class="text w180" readonly="readonly" />
              <input type="hidden" name="b_id" id="b_id" value="<?php echo $output['goods']['brand_id'];?>" />
              <em class="add-on"><i class="icon-collapse"></i></em></div>
            <div class="ncsc-brand-select-container">
              <div class="brand-index" data-tid="<?php echo $output['goods_class']['type_id'];?>" data-url="<?php echo urlShop('store_goods_add', 'ajax_get_brand');?>">
                <div class="letter" nctype="letter">
                  <ul>
                    <li><a href="javascript:void(0);" data-letter="all">全部品牌</a></li>
                    <li><a href="javascript:void(0);" data-letter="A">A</a></li>
                    <li><a href="javascript:void(0);" data-letter="B">B</a></li>
                    <li><a href="javascript:void(0);" data-letter="C">C</a></li>
                    <li><a href="javascript:void(0);" data-letter="D">D</a></li>
                    <li><a href="javascript:void(0);" data-letter="E">E</a></li>
                    <li><a href="javascript:void(0);" data-letter="F">F</a></li>
                    <li><a href="javascript:void(0);" data-letter="G">G</a></li>
                    <li><a href="javascript:void(0);" data-letter="H">H</a></li>
                    <li><a href="javascript:void(0);" data-letter="I">I</a></li>
                    <li><a href="javascript:void(0);" data-letter="J">J</a></li>
                    <li><a href="javascript:void(0);" data-letter="K">K</a></li>
                    <li><a href="javascript:void(0);" data-letter="L">L</a></li>
                    <li><a href="javascript:void(0);" data-letter="M">M</a></li>
                    <li><a href="javascript:void(0);" data-letter="N">N</a></li>
                    <li><a href="javascript:void(0);" data-letter="O">O</a></li>
                    <li><a href="javascript:void(0);" data-letter="P">P</a></li>
                    <li><a href="javascript:void(0);" data-letter="Q">Q</a></li>
                    <li><a href="javascript:void(0);" data-letter="R">R</a></li>
                    <li><a href="javascript:void(0);" data-letter="S">S</a></li>
                    <li><a href="javascript:void(0);" data-letter="T">T</a></li>
                    <li><a href="javascript:void(0);" data-letter="U">U</a></li>
                    <li><a href="javascript:void(0);" data-letter="V">V</a></li>
                    <li><a href="javascript:void(0);" data-letter="W">W</a></li>
                    <li><a href="javascript:void(0);" data-letter="X">X</a></li>
                    <li><a href="javascript:void(0);" data-letter="Y">Y</a></li>
                    <li><a href="javascript:void(0);" data-letter="Z">Z</a></li>
                    <li><a href="javascript:void(0);" data-letter="0-9">其他</a></li>
                  </ul>
                </div>
                <div class="search" nctype="search">
                  <input name="search_brand_keyword" id="search_brand_keyword" type="text" class="text" placeholder="品牌名称关键字查找"/><a href="javascript:void(0);" class="ncsc-btn-mini" style="vertical-align: top;">Go</a></div>
              </div>
              <div class="brand-list" nctype="brandList">
                <ul nctype="brand_list">
                  <?php if(is_array($output['brand_list']) && !empty($output['brand_list'])){?>
                  <?php foreach($output['brand_list'] as $val) { ?>
                  <li data-id='<?php echo $val['brand_id'];?>'data-name='<?php echo $val['brand_name'];?>'><em><?php echo $val['brand_initial'];?></em><?php echo $val['brand_name'];?></li>
                  <?php } ?>
                  <?php }?>
                </ul>
              </div>
              <div class="no-result" nctype="noBrandList" style="display: none;">没有符合"<strong>搜索关键字</strong>"条件的品牌</div>
            </div>
          </div>
        </dd>
      </dl>
      <?php }?>
      <?php if(is_array($output['attr_list']) && !empty($output['attr_list'])){?>
      <dl>
        <dt><?php echo $lang['store_goods_index_goods_attr'].$lang['nc_colon']; ?></dt>
        <dd>
          <?php foreach ($output['attr_list'] as $k=>$val){?>
          <span class="mr30">
          <label class="mr5"><?php echo $val['attr_name']?></label>
          <input type="hidden" name="attr[<?php echo $k;?>][name]" value="<?php echo $val['attr_name']?>" />
          <?php if(is_array($val) && !empty($val)){?>
          <select name="" attr="attr[<?php echo $k;?>][__NC__]" nc_type="attr_select">
            <option value='不限' nc_type='0'>不限</option>
            <?php foreach ($val['value'] as $v){?>
            <option value="<?php echo $v['attr_value_name']?>" <?php if(isset($output['attr_checked']) && in_array($v['attr_value_id'], $output['attr_checked'])){?>selected="selected"<?php }?> nc_type="<?php echo $v['attr_value_id'];?>"><?php echo $v['attr_value_name'];?></option>
            <?php }?>
          </select>
          <?php }?>
          </span>
          <?php }?>
        </dd>
      </dl>
      <?php }?>

      <?php
      if(!empty($_GET['commonid'])) {
      ?>
      <dl>
        <dt>规格名称：</dt>
        <dd>
          <input type="spec_name" value="<?php echo $goods_info['spec_name']?>" class='text valid'>
        </dd>
      </dl>
      <?php }?>
      <dl>
        <dt>
          <?php
          if (empty($_GET['commonid'])) {
            echo "商品规格：";
          }
          else{
            echo "商品关联：";
          }
          ?>

        </dt>
        <dd>
          <?php
          if(!empty($_GET['commonid'])) {
            $ginfo = Model()->table("goods")->where(array('goods_commonid' => $_GET['commonid']))->find();
            $gcinfo = Model()->table('goods_common')->find($_GET['commonid']);
            $specs = explode(',', $ginfo['link_goods']);
            $guige = array();
            foreach ($specs as $spec) {
                $_ginfo = Model()->table('goods')->where(array('goods_id'=>$spec))->find();
                $guige[] = $_ginfo['goods_serial'];
            }
            $guige = implode("\r\n", $guige);
          }
          else{
            $guige = '';
          }
          ?>
          <textarea name="goods_new_spec" id="" cols="30" rows="10" style="width:80%;min-height:200px;line-height: 25px;"><?php echo $guige;?></textarea>
          <?php if(empty($_GET['commonid'])){ ?>
          <p class="hint">
            请输入规格名称，系统将会自动生成相应的条目，并将规格补充到商品名称中，具体内容请自行编辑
            <br>
            规格名称一行为一个
            <br>
            格式为“补充名称 补充货号”，例如“红色 red-1”
            <br>
            此处填写时，商品货号以当前为准
          </p>
          <?php }else{ ?>

          <p class="hint">
            此处填写相关联的规格货号，在商品详情页会有跳转的链接，每行为一个货号，可任意连接
          </p>

          <?php }?>

        </dd>
      </dl>

      <dl>
        <dt><?php echo $lang['store_goods_index_goods_desc'].$lang['nc_colon'];?></dt>
        <dd id="ncProductDetails">
          <div class="tabs">
            <!-- <ul class="ui-tabs-nav" jquery1239647486215="2">
              <li class="ui-tabs-selected"><a href="#panel-1" jquery1239647486215="8"><i class="icon-desktop"></i> 电脑端</a></li>
              <li class="selected"><a href="#panel-2" jquery1239647486215="9"><i class="icon-mobile-phone"></i>手机端</a></li>
            </ul> -->
            <div id="panel-1" class="ui-tabs-panel" jquery1239647486215="4">
              <?php showEditor('g_body',$output['goods']['goods_body'],'100%','480px','visibility:hidden;',"false",$output['editor_multimedia']);?>
              <div class="hr8">
                <div class="ncsc-upload-btn"> <a href="javascript:void(0);"><span>
                  <input type="file" hidefocus="true" size="1" class="input-file" name="add_album" id="add_album" multiple="multiple">
                  </span>
                  <p><i class="icon-upload-alt" data_type="0" nctype="add_album_i"></i>图片上传</p>
                  </a> </div>
                <a class="ncsc-btn mt5" nctype="show_desc" href="index.php?act=store_album&op=pic_list&item=des"><i class="icon-picture"></i><?php echo $lang['store_goods_album_insert_users_photo'];?></a> <a href="javascript:void(0);" nctype="del_desc" class="ncsc-btn mt5" style="display: none;"><i class=" icon-circle-arrow-up"></i>关闭相册</a> </div>
              <p id="des_demo"></p>
            </div>
            <div id="panel-2" class="ui-tabs-panel ui-tabs-hide" jquery1239647486215="5">
              <div class="ncsc-mobile-editor">
                <div class="pannel">
                  <div class="size-tip"><span nctype="img_count_tip">图片总数得超过<em>20</em>张</span><i>|</i><span nctype="txt_count_tip">文字不得超过<em>5000</em>字</span></div>
                  <div class="control-panel" nctype="mobile_pannel">
                    <?php if (!empty($output['goods']['mb_body'])) {?>
                    <?php foreach ($output['goods']['mb_body'] as $val) {?>
                    <?php if ($val['type'] == 'text') {?>
                    <div class="module m-text">
                      <div class="tools"><a nctype="mp_up" href="javascript:void(0);">上移</a><a nctype="mp_down" href="javascript:void(0);">下移</a><a nctype="mp_edit" href="javascript:void(0);">编辑</a><a nctype="mp_del" href="javascript:void(0);">删除</a></div>
                      <div class="content">
                        <div class="text-div"><?php echo $val['value'];?></div>
                      </div>
                      <div class="cover"></div>
                    </div>
                    <?php }?>
                    <?php if ($val['type'] == 'image') {?>
                    <div class="module m-image">
                      <div class="tools"><a nctype="mp_up" href="javascript:void(0);">上移</a><a nctype="mp_down" href="javascript:void(0);">下移</a><a nctype="mp_rpl" href="javascript:void(0);">替换</a><a nctype="mp_del" href="javascript:void(0);">删除</a></div>
                      <div class="content">
                        <div class="image-div"><img src="<?php echo $val['value'];?>"></div>
                      </div>
                      <div class="cover"></div>
                    </div>
                    <?php }?>
                    <?php }?>
                    <?php }?>
                  </div>
                  <div class="add-btn">
                    <ul class="btn-wrap">
                      <li><a href="javascript:void(0);" nctype="mb_add_img"><i class="icon-picture"></i>
                        <p>图片</p>
                        </a></li>
                      <li><a href="javascript:void(0);" nctype="mb_add_txt"><i class="icon-font"></i>
                        <p>文字</p>
                        </a></li>
                    </ul>
                  </div>
                </div>
                <div class="explain">
                  <dl>
                    <dt>1、基本要求：</dt>
                    <dd>（1）手机详情总体大小：图片+文字，图片不超过20张，文字不超过5000字；</dd>
                    <dd>建议：所有图片都是本宝贝相关的图片。</dd>
                  </dl><dl>
                    <dt>2、图片大小要求：</dt>
                    <dd>（1）建议使用宽度480 ~ 620像素、高度小于等于960像素的图片；</dd>
                    <dd>（2）格式为：JPG\JEPG\GIF\PNG；</dd>
                    <dd>举例：可以上传一张宽度为480，高度为960像素，格式为JPG的图片。</dd>
                  </dl><dl>
                    <dt>3、文字要求：</dt>
                    <dd>（1）每次插入文字不能超过500个字，标点、特殊字符按照一个字计算；</dd>
                    <dd>建议：不要添加太多的文字，这样看起来更清晰。</dd>
                  </dl>
                </div>
              </div>
              <div class="ncsc-mobile-edit-area" nctype="mobile_editor_area">
                <div nctype="mea_img" class="ncsc-mea-img" style="display: none;"></div>
                <div class="ncsc-mea-text" nctype="mea_txt" style="display: none;">
                  <p id="meat_content_count" class="text-tip"></p>
                  <textarea class="textarea valid" nctype="meat_content"></textarea>
                  <div class="button"><a class="ncsc-btn ncsc-btn-blue" nctype="meat_submit" href="javascript:void(0);">确认</a><a class="ncsc-btn ml10" nctype="meat_cancel" href="javascript:void(0);">取消</a></div>
                  <a class="text-close" nctype="meat_cancel" href="javascript:void(0);">X</a>
                </div>
              </div>
              <input name="m_body" autocomplete="off" type="hidden" value='<?php echo $output['goods']['mobile_body'];?>'>
            </div>
          </div>
        </dd>
      </dl>

      <input type="hidden" name="is_presell" value='0'/>
      <input type="hidden" name="is_fc" value='0'/>
      <input type="hidden" name="is_gv" value='0'/>

      <!-- 商品物流信息 S -->
      <h3 id="demo4"><?php echo $lang['store_goods_index_goods_transport']?></h3>
      <dl>
        <dt><?php echo $lang['store_goods_index_goods_szd'].$lang['nc_colon']?></dt>
        <dd>
          <p id="region">
            <select class="d_inline" name="province_id" id="province_id">
            </select>
          </p>
        </dd>
      </dl>
      <dl nctype="virtual_null" <?php if ($output['goods']['is_virtual'] == 1) {?>style="display:none;"<?php }?>>
        <dt><?php echo $lang['store_goods_index_goods_transfee_charge'].$lang['nc_colon']; ?></dt>
        <dd>
          <ul class="ncsc-form-radio-list">
            <li>
              <input id="freight_0" nctype="freight" name="freight" class="radio" type="radio" <?php if (intval($output['goods']['transport_id']) == 0) {?>checked="checked"<?php }?> value="0">
              <label for="freight_0">固定运费</label>
              <div nctype="div_freight" <?php if (intval($output['goods']['transport_id']) != 0) {?>style="display: none;"<?php }?>>
                <input id="g_freight" class="w50 text" nc_type='transport' type="text" value="<?php printf('%.2f', floatval($output['goods']['goods_freight']));?>" name="g_freight"><em class="add-on"><i class="icon-renminbi"></i></em> </div>
            </li>
            <li>
              <input id="freight_1" nctype="freight" name="freight" class="radio" type="radio" <?php if (intval($output['goods']['transport_id']) != 0) {?>checked="checked"<?php }?> value="1">
              <label for="freight_1"><?php echo $lang['store_goods_index_use_tpl'];?></label>
              <div nctype="div_freight" <?php if (intval($output['goods']['transport_id']) == 0) {?>style="display: none;"<?php }?>>
                <input id="transport_id" type="hidden" value="<?php echo $output['goods']['transport_id'];?>" name="transport_id">
                <input id="transport_title" type="hidden" value="<?php echo $output['goods']['transport_title'];?>" name="transport_title">
                <span id="postageName" class="transport-name" <?php if ($output['goods']['transport_title'] != '') {?>style="display: inline-block;"<?php }?>><?php echo $output['goods']['transport_title'];?></span><a href="JavaScript:void(0);" onclick="window.open('index.php?act=store_transport&type=select')" class="ncsc-btn" id="postageButton"><i class="icon-truck"></i><?php echo $lang['store_goods_index_select_tpl'];?></a> </div>
            </li>
          </ul>
          <p class="hint">运费设置为 0 元，前台商品将显示为免运费。</p>
        </dd>
      </dl>
      <!-- 商品物流信息 E -->
      <h3 id="demo5" nctype="virtual_null" <?php if ($output['goods']['is_virtual'] == 1) {?>style="display:none;"<?php }?>>发票信息</h3>
      <dl nctype="virtual_null" <?php if ($output['goods']['is_virtual'] == 1) {?>style="display:none;"<?php }?>>
        <dt>是否开增值税发票：</dt>
        <dd>
          <ul class="ncsc-form-radio-list">
            <li>
              <label>
                <input name="g_vat" value="1" <?php if (!empty($output['goods']) && $output['goods']['goods_vat'] == 1) { ?>checked="checked" <?php } ?> type="radio" />
                <?php echo $lang['nc_yes'];?></label>
            </li>
            <li>
              <label>
                <input name="g_vat" value="0" <?php if (empty($output['goods']) || $output['goods']['goods_vat'] == 0) { ?>checked="checked" <?php } ?> type="radio"/>
                <?php echo $lang['nc_no'];?></label>
            </li>
          </ul>
          <p class="hint"></p>
        </dd>
      </dl>
      <?php
        if(dis_open()){
      ?>
      <h3>
        分销设置
      </h3>
      <dl>
        <dt>商品是否允许分销：</dt>
        <dd>
          <ul class='ncsc-form-radio-list distribute' >
            <li>
              <label>
                <input name="agree_distribute" value="1" <?php if($gminfo['agree_distribute'] > 0) echo 'checked';?> type="radio">
                是
              </label>

            </li>
            <li>
              <label>
                <input name="agree_distribute" value="0" <?php if(!isset($gminfo['agree_distribute']) || !$gminfo['agree_distribute']) echo 'checked'?> type="radio">
                否
              </label>
            </li>
          </ul>
        </dd>
      </dl>
      <dl>
        <dt>
          分销利润：
        </dt>
        <dd>
          <div>
            <?php
              if(isset($gminfo['distribute_rate'])){
                $distribute = unserialize($gminfo['distribute_rate']);
              }
              else{
                $distribute = array();
              }

            ?>


            <input type="text" class='w50 text valid' name='distribute_rate[0]' value='<?php echo $distribute[0]?>'>
            <em class="add-on" style="margin-left:-4px">%</em>

            <p class="hint">
              一级分销利润
            </p>
          </div>
          <div style="margin-top: 10px;">
            <input type="text" class='w50 text valid' name='distribute_rate[1]' value='<?php echo $distribute[1]?>'>
            <em class="add-on" style="margin-left:-4px">%</em>

            <p class="hint">
              二级分销利润
            </p>
          </div>
          <div style='margin-top: 10px;'>
            <input type="text" class='w50 text valid' name='distribute_rate[2]' value='<?php echo $distribute[2]?>'>
            <em class="add-on" style="margin-left:-4px">%</em>

            <p class="hint">
              三级分销利润
            </p>
          </div>
        </dd>

      </dl>
      <?php
        }
      ?>
      <h3 id="demo6"><?php echo $lang['store_goods_index_goods_other_info']?></h3>
      <dl>
        <dt><?php echo $lang['store_goods_index_store_goods_class'].$lang['nc_colon'];?></dt>
        <dd><span class="new_add"><a href="javascript:void(0)" id="add_sgcategory" class="ncsc-btn"><?php echo $lang['store_goods_index_new_class'];?></a> </span>
          <?php if (!empty($output['store_class_goods'])) { ?>
          <?php foreach ($output['store_class_goods'] as $v) { ?>
          <select name="sgcate_id[]" class="sgcategory">
            <option value="0"><?php echo $lang['nc_please_choose'];?></option>
            <?php foreach ($output['store_goods_class'] as $val) { ?>
            <option value="<?php echo $val['stc_id']; ?>" <?php if ($v==$val['stc_id']) { ?>selected="selected"<?php } ?>><?php echo $val['stc_name']; ?></option>
            <?php if (is_array($val['child']) && count($val['child'])>0){?>
            <?php foreach ($val['child'] as $child_val){?>
            <option value="<?php echo $child_val['stc_id']; ?>" <?php if ($v==$child_val['stc_id']) { ?>selected="selected"<?php } ?>>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $child_val['stc_name']; ?></option>
            <?php }?>
            <?php }?>
            <?php } ?>
          </select>
          <?php } ?>
          <?php } else { ?>
          <select name="sgcate_id[]" class="sgcategory">
            <option value="0"><?php echo $lang['nc_please_choose'];?></option>
            <?php if (!empty($output['store_goods_class'])){?>
            <?php foreach ($output['store_goods_class'] as $val) { ?>
            <option value="<?php echo $val['stc_id']; ?>"><?php echo $val['stc_name']; ?></option>
            <?php if (is_array($val['child']) && count($val['child'])>0){?>
            <?php foreach ($val['child'] as $child_val){?>
            <option value="<?php echo $child_val['stc_id']; ?>">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $child_val['stc_name']; ?></option>
            <?php }?>
            <?php }?>
            <?php } ?>
            <?php } ?>
          </select>
          <?php } ?>
          <p class="hint"><?php echo $lang['store_goods_index_belong_multiple_store_class'];?></p>
        </dd>
      </dl>
      <dl style='display: none;'>
        <dt><?php echo $lang['store_goods_index_goods_show'].$lang['nc_colon'];?></dt>
        <dd>
          <ul class="ncsc-form-radio-list">
            <li>
              <label>
                <input name="g_state" value="1" type="radio" <?php if (empty($output['goods']) || $output['goods']['goods_state'] == 1 || $output['goods']['goods_state'] == 10) {?>checked="checked"<?php }?> />
                <?php echo $lang['store_goods_index_immediately_sales'];?> </label>
            </li>
            <li>
              <label>
                <input name="g_state" value="0" type="radio" nctype="auto" />
                <?php echo $lang['store_goods_step2_start_time'];?> </label>
              <input type="text" class="w80 text" name="starttime" disabled="disabled" style="background:#E7E7E7 none;" id="starttime" value="<?php echo date('Y-m-d');?>" />
              <select disabled="disabled" style="background:#E7E7E7 none;" name="starttime_H" id="starttime_H">
                <?php foreach ($output['hour_array'] as $val){?>
                <option value="<?php echo $val;?>" <?php $sign_H = 0;if($val>=date('H') && $sign_H != 1){?>selected="selected"<?php $sign_H = 1;}?>><?php echo $val;?></option>
                <?php }?>
              </select>
              <?php echo $lang['store_goods_step2_hour'];?>
              <select disabled="disabled" style="background:#E7E7E7 none;" name="starttime_i" id="starttime_i">
                <?php foreach ($output['minute_array'] as $val){?>
                <option value="<?php echo $val;?>" <?php $sign_i = 0;if($val>=date('i') && $sign_i != 1){?>selected="selected"<?php $sign_i = 1;}?>><?php echo $val;?></option>
                <?php }?>
              </select>
              <?php echo $lang['store_goods_step2_minute'];?> </li>
            <li>
              <label>
                <input name="g_state" value="0" type="radio" <?php if (!empty($output['goods']) && $output['goods']['goods_state'] == 0) {?>checked="checked"<?php }?> />
                <?php echo $lang['store_goods_index_in_warehouse'];?> </label>
            </li>
          </ul>
        </dd>
      </dl>
      <input type='hidden' value='0' name='is_appoint' />
      <dl>
        <dt><?php echo $lang['store_goods_index_goods_recommend'].$lang['nc_colon'];?></dt>
        <dd>
          <ul class="ncsc-form-radio-list">
            <li>
              <label>
                <input name="g_commend" value="1" <?php if (empty($output['goods']) || $output['goods']['goods_commend'] == 1) { ?>checked="checked" <?php } ?> type="radio" />
                <?php echo $lang['nc_yes'];?></label>
            </li>
            <li>
              <label>
                <input name="g_commend" value="0" <?php if (!empty($output['goods']) && $output['goods']['goods_commend'] == 0) { ?>checked="checked" <?php } ?> type="radio"/>
                <?php echo $lang['nc_no'];?></label>
            </li>
          </ul>
          <p class="hint"><?php echo $lang['store_goods_index_recommend_tip'];?></p>
        </dd>
      </dl>
    </div>
    <div class="bottom tc hr32">
      <label class="submit-border" onclick='return chkfirst()'>
        <input type="submit" class="submit" value="<?php if ($output['edit_goods_sign']) {echo '提交';} else {?><?php echo $lang['store_goods_add_next'];?>，上传商品图片<?php }?>" />
      </label>
    </div>
  </form>
</div>
<script type="text/javascript">
var SITEURL = "<?php echo SHOP_SITE_URL; ?>";
var DEFAULT_GOODS_IMAGE = "<?php echo thumb(array(), 60);?>";
var SHOP_RESOURCE_SITE_URL = "<?php echo SHOP_RESOURCE_SITE_URL;?>";

$(function(){
	//电脑端手机端tab切换
	$(".tabs").tabs();

    $.validator.addMethod('checkPrice', function(value,element){
    	_g_price = parseFloat($('input[name="g_price"]').val());
        _g_marketprice = parseFloat($('input[name="g_marketprice"]').val());
        if (_g_price > _g_marketprice) {
            return false;
        }else {
            return true;
        }
    }, '<i class="icon-exclamation-sign"></i>商品价格不能高于市场价格');
	jQuery.validator.addMethod("checkFCodePrefix", function(value, element) {
		return this.optional(element) || /^[a-zA-Z]+$/.test(value);
	},'<i class="icon-exclamation-sign"></i>请填写不多于5位的英文字母');
    var valiRules = {
        errorPlacement: function(error, element){
            $(element).nextAll('span').append(error);
        },
        <?php if ($output['edit_goods_sign']) {?>
        submitHandler:function(form){
            ajaxpost('goods_form', '', '', 'onerror');
        },
        <?php }?>
        rules : {
            g_name : {
                required    : true,
                minlength   : 3,
                maxlength   : 50
            },
            g_jingle : {
                maxlength   : 140
            },
            g_price : {
                required    : true,
                number      : true,
                min         : 0.01,
                max         : 9999999,
                checkPrice  : true
            },
            g_marketprice : {
                required    : true,
                number      : true,
                min         : 0.01,
                max         : 9999999
            },
            g_costprice : {
                number      : true,
                min         : 0.00,
                max         : 9999999
            },
            g_storage  : {
                required    : true,
                digits      : true,
                min         : 0,
                max         : 999999999
            },
            g_serial : {
                required : false
            },
            image_path : {
                required    : true
            },
            g_vindate : {
                required    : function() {if ($("#is_gv_1").prop("checked")) {return true;} else {return false;}}
            },
            g_vlimit : {
                required    : function() {if ($("#is_gv_1").prop("checked")) {return true;} else {return false;}},
                range       : [1,10]
            },
            g_fccount : {
                <?php if (!$output['edit_goods_sign']) {?>required  : function() {if ($("#is_fc_1").prop("checked")) {return true;} else {return false;}},<?php }?>
                range       : [1,100]
            },
            g_fcprefix : {
                <?php if (!$output['edit_goods_sign']) {?>required  : function() {if ($("#is_fc_1").prop("checked")) {return true;} else {return false;}},<?php }?>
                checkFCodePrefix : true,
                rangelength : [3,5]
            },
            g_saledate : {
                required    : function () {if ($('#is_appoint_1').prop("checked")) {return true;} else {return false;}}
            },
            g_deliverdate : {
                required    : function () {if ($('#is_presell_1').prop("checked")) {return true;} else {return false;}}
            },
      <?php if($config['open_tax'] == 1){ ?>
      // margin : {
      //   required : function(){
      //     if($('[name=goods_type]:checked').val() == 1){
      //       var val = $.trim($('[name=margin]').val());
      //       if(/^[0-9]+$/.test(val) && val > 0 && val < 100){
      //         return false;
      //       }
      //       return true;
      //     }

      //     return false;
      //   }
      // }
      <?php }?>
        },
        messages : {
            g_name  : {
                required    : '<i class="icon-exclamation-sign"></i><?php echo $lang['store_goods_index_goods_name_null'];?>',
                minlength   : '<i class="icon-exclamation-sign"></i><?php echo $lang['store_goods_index_goods_name_help'];?>',
                maxlength   : '<i class="icon-exclamation-sign"></i><?php echo $lang['store_goods_index_goods_name_help'];?>'
            },
            g_jingle : {
                maxlength   : '<i class="icon-exclamation-sign"></i>商品卖点不能超过140个字符'
            },
            g_price : {
                required    : '<i class="icon-exclamation-sign"></i><?php echo $lang['store_goods_index_store_price_null'];?>',
                number      : '<i class="icon-exclamation-sign"></i><?php echo $lang['store_goods_index_store_price_error'];?>',
                min         : '<i class="icon-exclamation-sign"></i><?php echo $lang['store_goods_index_store_price_interval'];?>',
                max         : '<i class="icon-exclamation-sign"></i><?php echo $lang['store_goods_index_store_price_interval'];?>'
            },
            g_marketprice : {
                required    : '<i class="icon-exclamation-sign"></i>请填写市场价',
                number      : '<i class="icon-exclamation-sign"></i>请填写正确的价格',
                min         : '<i class="icon-exclamation-sign"></i>请填写0.01~9999999之间的数字',
                max         : '<i class="icon-exclamation-sign"></i>请填写0.01~9999999之间的数字'
            },
            g_costprice : {
                number      : '<i class="icon-exclamation-sign"></i>请填写正确的价格',
                min         : '<i class="icon-exclamation-sign"></i>请填写0.00~9999999之间的数字',
                max         : '<i class="icon-exclamation-sign"></i>请填写0.00~9999999之间的数字'
            },
            g_storage : {
                required    : '<i class="icon-exclamation-sign"></i><?php echo $lang['store_goods_index_goods_stock_null'];?>',
                digits      : '<i class="icon-exclamation-sign"></i><?php echo $lang['store_goods_index_goods_stock_error'];?>',
                min         : '<i class="icon-exclamation-sign"></i><?php echo $lang['store_goods_index_goods_stock_checking'];?>',
                max         : '<i class="icon-exclamation-sign"></i><?php echo $lang['store_goods_index_goods_stock_checking'];?>'
            },
            g_serial : {
                required : '<i class="icon-exclamation-sign"></i>请填写商家货号'
            },
            image_path : {
                required    : '<i class="icon-exclamation-sign"></i>请设置商品主图'
            },
            g_vindate : {
                required    : '<i class="icon-exclamation-sign"></i>请选择有效期'
            },
            g_vlimit : {
                required    : '<i class="icon-exclamation-sign"></i>请填写1~10之间的数字',
                range       : '<i class="icon-exclamation-sign"></i>请填写1~10之间的数字'
            },
            g_fccount : {
                required    : '<i class="icon-exclamation-sign"></i>请填写1~100之间的数字',
                range       : '<i class="icon-exclamation-sign"></i>请填写1~100之间的数字'
            },
            g_fcprefix : {
                required    : '<i class="icon-exclamation-sign"></i>请填写3~5位的英文字母',
                rangelength : '<i class="icon-exclamation-sign"></i>请填写3~5位的英文字母'
            },
            g_saledate : {
                required    : '<i class="icon-exclamation-sign"></i>请选择有效期'
            },
            g_deliverdate : {
                required    : '<i class="icon-exclamation-sign"></i>请选择有效期'
            },
      <?php
        if($config['open_tax'] == 1){
      ?>
      margin:{
        required : '<i class="icon-exclamation-sign"></i>请填写正确的税率'
        }
      }
      <?php }?>
    };
    $('#goods_form').validate(valiRules);
    <?php if (isset($output['goods'])) {?>
	setTimeout("setArea(<?php echo $output['goods']['areaid_1'];?>, <?php echo $output['goods']['areaid_2'];?>)", 1000);
	<?php }?>
});
// 按规格存储规格值数据
var spec_group_checked = [<?php for ($i=0; $i<$output['sign_i']; $i++){if($i+1 == $output['sign_i']){echo "''";}else{echo "'',";}}?>];
var str = '';
var V = new Array();

<?php for ($i=0; $i<$output['sign_i']; $i++){?>
var spec_group_checked_<?php echo $i;?> = new Array();
<?php }?>

$(function(){
	$('dl[nctype="spec_group_dl"]').on('click', 'span[nctype="input_checkbox"] > input[type="checkbox"]',function(){
		into_array();
		goods_stock_set();
	});

	// 提交后不没有填写的价格或库存的库存配置设为默认价格和0
	// 库存配置隐藏式 里面的input加上disable属性
	$('input[type="submit"]').click(function(){
		$('input[data_type="price"]').each(function(){
			if($(this).val() == ''){
				$(this).val($('input[name="g_price"]').val());
			}
		});
		$('input[data_type="stock"]').each(function(){
			if($(this).val() == ''){
				$(this).val('0');
			}
		});
		$('input[data_type="alarm"]').each(function(){
			if($(this).val() == ''){
				$(this).val('0');
			}
		});
		if($('dl[nc_type="spec_dl"]').css('display') == 'none'){
			$('dl[nc_type="spec_dl"]').find('input').attr('disabled','disabled');
		}
	});

});

// 将选中的规格放入数组
function into_array(){
<?php for ($i=0; $i<$output['sign_i']; $i++){?>

		spec_group_checked_<?php echo $i;?> = new Array();
		$('dl[nc_type="spec_group_dl_<?php echo $i;?>"]').find('input[type="checkbox"]:checked').each(function(){
			i = $(this).attr('nc_type');
			v = $(this).val();
			c = null;
			if ($(this).parents('dl:first').attr('spec_img') == 't') {
				c = 1;
			}
			spec_group_checked_<?php echo $i;?>[spec_group_checked_<?php echo $i;?>.length] = [v,i,c];
		});

		spec_group_checked[<?php echo $i;?>] = spec_group_checked_<?php echo $i;?>;

<?php }?>
}

// 生成库存配置
function goods_stock_set(){
    //  店铺价格 商品库存改为只读
    $('input[name="g_price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
    $('input[name="g_storage"]').attr('readonly','readonly').css('background','#E7E7E7 none');

    $('dl[nc_type="spec_dl"]').show();
    str = '<tr>';
    <?php recursionSpec(0,$output['sign_i']);?>
    if(str == '<tr>'){
        //  店铺价格 商品库存取消只读
        $('input[name="g_price"]').removeAttr('readonly').css('background','');
        $('input[name="g_storage"]').removeAttr('readonly').css('background','');
        $('dl[nc_type="spec_dl"]').hide();
    }else{
        $('tbody[nc_type="spec_table"]').empty().html(str)
            .find('input[nc_type]').each(function(){
                s = $(this).attr('nc_type');
                try{$(this).val(V[s]);}catch(ex){$(this).val('');};
                if ($(this).attr('data_type') == 'marketprice' && $(this).val() == '') {
                    $(this).val($('input[name="g_marketprice"]').val());
                }
                if ($(this).attr('data_type') == 'price' && $(this).val() == ''){
                    $(this).val($('input[name="g_price"]').val());
                }
                if ($(this).attr('data_type') == 'stock' && $(this).val() == ''){
                    $(this).val('0');
                }
                if ($(this).attr('data_type') == 'alarm' && $(this).val() == ''){
                    $(this).val('0');
                }
            }).end()
            .find('input[data_type="stock"]').change(function(){
                computeStock();    // 库存计算
            }).end()
            .find('input[data_type="price"]').change(function(){
                computePrice();     // 价格计算
            }).end()
            .find('input[nc_type]').change(function(){
                s = $(this).attr('nc_type');
                V[s] = $(this).val();
            });
    }
}

<?php
/**
 *
 *
 *  生成需要的js循环。递归调用	PHP
 *
 *  形式参考 （ 2个规格）
 *  $('input[type="checkbox"]').click(function(){
 *      str = '';
 *      for (var i=0; i<spec_group_checked[0].length; i++ ){
 *      td_1 = spec_group_checked[0][i];
 *          for (var j=0; j<spec_group_checked[1].length; j++){
 *              td_2 = spec_group_checked[1][j];
 *              str += '<tr><td>'+td_1[0]+'</td><td>'+td_2[0]+'</td><td><input type="text" /></td><td><input type="text" /></td><td><input type="text" /></td>';
 *          }
 *      }
 *      $('table[class="spec_table"] > tbody').empty().html(str);
 *  });
 */
function recursionSpec($len,$sign) {
    if($len < $sign){
        echo "for (var i_".$len."=0; i_".$len."<spec_group_checked[".$len."].length; i_".$len."++){td_".(intval($len)+1)." = spec_group_checked[".$len."][i_".$len."];\n";
        $len++;
        recursionSpec($len,$sign);
    }else{
        echo "var tmp_spec_td = new Array();\n";
        for($i=0; $i< $len; $i++){
            echo "tmp_spec_td[".($i)."] = td_".($i+1)."[1];\n";
        }
        echo "tmp_spec_td.sort(function(a,b){return a-b});\n";
        echo "var spec_bunch = 'i_';\n";
        for($i=0; $i< $len; $i++){
            echo "spec_bunch += tmp_spec_td[".($i)."];\n";
        }
        echo "str += '<input type=\"hidden\" name=\"spec['+spec_bunch+'][goods_id]\" nc_type=\"'+spec_bunch+'|id\" value=\"\" />';";
        for($i=0; $i< $len; $i++){
            echo "if (td_".($i+1)."[2] != null) { str += '<input type=\"hidden\" name=\"spec['+spec_bunch+'][color]\" value=\"'+td_".($i+1)."[1]+'\" />';}";
            echo "str +='<td><input type=\"hidden\" name=\"spec['+spec_bunch+'][sp_value]['+td_".($i+1)."[1]+']\" value=\"'+td_".($i+1)."[0]+'\" />'+td_".($i+1)."[0]+'</td>';\n";
        }
        echo "str +='<td><input class=\"text price\" type=\"text\" name=\"spec['+spec_bunch+'][marketprice]\" data_type=\"marketprice\" nc_type=\"'+spec_bunch+'|marketprice\" value=\"\" /><em class=\"add-on\"><i class=\"icon-renminbi\"></i></em></td><td><input class=\"text price\" type=\"text\" name=\"spec['+spec_bunch+'][price]\" data_type=\"price\" nc_type=\"'+spec_bunch+'|price\" value=\"\" /><em class=\"add-on\"><i class=\"icon-renminbi\"></i></em></td><td><input class=\"text stock\" type=\"text\" name=\"spec['+spec_bunch+'][stock]\" data_type=\"stock\" nc_type=\"'+spec_bunch+'|stock\" value=\"\" /></td><td><input class=\"text stock\" type=\"text\" name=\"spec['+spec_bunch+'][alarm]\" data_type=\"alarm\" nc_type=\"'+spec_bunch+'|alarm\" value=\"\" /></td><td><input class=\"text sku\" type=\"text\" name=\"spec['+spec_bunch+'][sku]\" nc_type=\"'+spec_bunch+'|sku\" value=\"\" /></td></tr>';\n";
        for($i=0; $i< $len; $i++){
            echo "}\n";
        }
    }
}

?>

// $('#goods_form').submit(function(){
//   if($('[name=goods_type]:checked').val() == 1){
//     var margin = $('[name=g_price]').val();
//     if(!/[0-9]+/.test(margin) || margin < 0 || margin > 100){
//       layer.msg('请填写正确的税率！');
//       return false;
//     }
//   }
// });

<?php if (!empty($output['goods']) && $_GET['class_id'] <= 0 && !empty($output['sp_value']) && !empty($output['spec_checked']) && !empty($output['spec_list'])){?>
//  编辑商品时处理JS
$(function(){
	var E_SP = new Array();
	var E_SPV = new Array();
	<?php
	$string = '';
	foreach ($output['spec_checked'] as $v) {
		$string .= "E_SP[".$v['id']."] = '".$v['name']."';";
	}
	echo $string;
	echo "\n";
	$string = '';
	foreach ($output['sp_value'] as $k=>$v) {
		$string .= "E_SPV['{$k}'] = '{$v}';";
	}
	echo $string;
	?>
	V = E_SPV;
	$('dl[nc_type="spec_dl"]').show();
	$('dl[nctype="spec_group_dl"]').find('input[type="checkbox"]').each(function(){
		//  店铺价格 商品库存改为只读
		$('input[name="g_price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
		$('input[name="g_storage"]').attr('readonly','readonly').css('background','#E7E7E7 none');
		s = $(this).attr('nc_type');
		if (!(typeof(E_SP[s]) == 'undefined')){
			$(this).attr('checked',true);
			v = $(this).parents('li').find('span[nctype="pv_name"]');
			if(E_SP[s] != ''){
				$(this).val(E_SP[s]);
				v.html('<input type="text" maxlength="20" value="'+E_SP[s]+'" />');
			}else{
				v.html('<input type="text" maxlength="20" value="'+v.html()+'" />');
			}
			change_img_name($(this));			// 修改相关的颜色名称
		}
	});

    into_array();	// 将选中的规格放入数组
    str = '<tr>';
    <?php recursionSpec(0,$output['sign_i']);?>
    if(str == '<tr>'){
        $('dl[nc_type="spec_dl"]').hide();
        $('input[name="g_price"]').removeAttr('readonly').css('background','');
        $('input[name="g_storage"]').removeAttr('readonly').css('background','');
    }else{
        $('tbody[nc_type="spec_table"]').empty().html(str)
            .find('input[nc_type]').each(function(){
                s = $(this).attr('nc_type');
                try{$(this).val(E_SPV[s]);}catch(ex){$(this).val('');};
            }).end()
            .find('input[data_type="stock"]').change(function(){
                computeStock();    // 库存计算
            }).end()
            .find('input[data_type="price"]').change(function(){
                computePrice();     // 价格计算
            }).end()
            .find('input[type="text"]').change(function(){
                s = $(this).attr('nc_type');
                V[s] = $(this).val();
            });
    }
});
<?php }?>

function chkfirst(){
  if($('[name=goods_type]:checked').val() == 1){

    if(confirm("您选择了保税商品，请认真填写保税商品相关信息，否则可能无法正常上架！")){
      $('#_result ._extends').remove();
      $('#_result').find('input,select').each(function(){
        if(this.name.indexOf('[') > -1){
          return;
        }
        var input = $('<input>').attr({"type" : "hidden",name : 'goodsextends[' + this.name + ']' ,value : this.value,"class":"_extends"}).appendTo($('#_result'));
      });
      return true;
    }
    return false;
  }
}
</script>
<script src="<?php echo SHOP_RESOURCE_SITE_URL;?>/js/scrolld.js"></script>
<script type="text/javascript">$("[id*='Btn']").stop(true).on('click', function (e) {e.preventDefault();$(this).scrolld();})</script>
